import fetch from '../models/fetch'
const indexTpl = require('../views/index.html')
const position = require('../views/position.html')
const listItemTpl = require('../views/list_item.html')
const starlistItemTpl = require('../views/superstar_list.html')



const render = async() => {
    let res = await fetch.get('damaijson/external/gl.html')
    let data = res.suggest// list数据的获取
    console.log(data)

    let starres = await fetch.stardata('myjson/stardata')
    let stardata = starres.data// star数据的获取
    console.log(stardata);

    // 首页大结构
    $('#app').html(indexTpl)// zepto编写

    // 主体部分
    document.querySelector('main').innerHTML = position// 原生js编写

    

    // 产品列表渲染
    let renderListTpl = template.render(listItemTpl, {data})
    $('#list').html(renderListTpl)

    // star列表渲染
    let renderstarTpl = template.render(starlistItemTpl, {stardata})
    $('.star_list_wrap').html(renderstarTpl)

    // 下拉弹弹弹
    new BScroll('main')
}


// 模块暴露
export default {
    render
}





// 无法用commonjs
// const  fetch = require('../models/fetch')

// const render = async() => {
//     let data = await fetch.get('damaijson/external/gl.html')
//     console.log(data);
// }

// module.exports = {
//     render
// }